home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: cdf.toronto.edu!news
- From: p a u l <a209dowm>
- Subject: help! getting EOF in the middle of the file!
- Content-Type: text/plain; charset=us-ascii
- Message-ID: <DpDL8o.6xs@cdf.toronto.edu>
- Sender: news@cdf.toronto.edu (Usenet News)
- Nntp-Posting-Host: tonnyx
- Content-Transfer-Encoding: 7bit
- Organization: Computing Disciplines Facility, University of Toronto
- Mime-Version: 1.0
- Date: Fri, 5 Apr 1996 06:12:22 GMT
- X-Mailer: Mozilla 1.1N (X11; I; SunOS 5.3 sun4c)
- X-Url: news:comp.lang.c++
-
- I have a program that was working fine using cin, and I tried to change it so
- it reads from a file.
-
- It was working with the exact same data file before when I used:
- a.out < datafile
-
- now it doesn't work, see the code below:
-
- int x;
- ifstream in_stream;
-
- // in_stream is open and I'm reading from it no problem.
- // I'm halfway through the input file, and in_stream.eof() == 0 right now
-
- x = in_stream.get();
-
- // now in_stream.eof() == 1
- // but I haven't reached the end of the file!!
-
- What could be going wrong here? Any suggestions would be greatly appreciated.
-
- Thanks,
- Paul.
-
-